package com.bsj.media.tool.dto;


import com.bsj.tools.Conv;
import lombok.Data;

@Data
public class SendFDDataInfo extends SendData {


    /**
     * 多媒体数据
     * @return
     */
    @Override
    public byte[] getNeedData() {
        int offset = 0;
        int bodyLen = getData().length;
        int len = 1 + 1 + 1 + 1 + 1 + 8 + 8 + bodyLen;
        byte[] result = new byte[len];
        //通道
        result[offset++] = (byte) (getChannelNo() & 0xFF);
        //数据类型
        result[offset++] = (byte) (getDataType() & 0xFF);
        //编码格式
        result[offset++] = (byte) getPayLoad();
        // 采样位数 分辨率
        offset++;
        // 视频帧率
        result[offset++] = (byte) getNRate();
        //时间戳
        Conv.setLongNetOrder(result, offset, getTime());
        offset = offset + 8;
        //包序号,多媒体ID，前面四位表示索引
        Conv.setShortNetOrder(result, offset, getPageNo());
        offset = offset + 8;
        // body数据
        System.arraycopy(getData(), 0, result, offset, bodyLen);
        offset += bodyLen;
        return result;
    }
}
